package com.zlcx.tz.live.processor.impl;

import com.zlcx.tz.live.domain.TimeLearnRoomUsersDO;
import com.zlcx.tz.live.processor.QuitRoomPostProcessor;
import com.zlcx.tz.live.service.TimeLearnRoomDialogStore;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author: anjl
 * @description: 移除会话中房间用户（同样作为房间内用户信息，用于同步房间内的弹幕消息）
 * @data: 2020-09-29
 **/
@Slf4j
@Component
public class QuitRoomDialogPostProcessor implements QuitRoomPostProcessor<TimeLearnRoomUsersDO> {

    @Override
    public void processor(TimeLearnRoomUsersDO roomUsers) {
        asyncTaskExecutor.submit(() -> {
            timeLearnRoomDialogStore.remove(roomUsers.getRoomId(), roomUsers.getUserId());
            log.info("计时房间操作-移除redis房间用户 roomUsers = {}", roomUsers);
        });
    }

    @Autowired
    private TimeLearnRoomDialogStore timeLearnRoomDialogStore;
    @Resource(name = "taskExecutor")
    AsyncTaskExecutor asyncTaskExecutor;
}
